package com.googlecode.classgrep.visitor.invoker;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.commons.EmptyVisitor;

import com.googlecode.classgrep.entity.invoker.LocalVariableSignature;

/**
 * get info for each method use LocalVariableInfoFetchVisitor
 * 
 * @see LocalVariableInfoFetchVisitor
 *
 */
public class AllMethodLocalVarInfoFetchVisitor extends EmptyVisitor {

	private Map<String, List<LocalVariableSignature>> allVarSigns;
	
	
	public AllMethodLocalVarInfoFetchVisitor(Map<String, List<LocalVariableSignature>> allVarSigns) {
		super();
		this.allVarSigns = allVarSigns;
	}


	/**
	 * 
	 * @param name
	 * @param desc
	 * @return
	 */
	public static String getKey(String name, String desc) {
		return name + "_" + desc;
	}
	

	@Override
	public MethodVisitor visitMethod(int access, String name, String desc,
			String signature, String[] exceptions) {
		List<LocalVariableSignature> varSign = new ArrayList<LocalVariableSignature>();
		allVarSigns.put(getKey(name, desc), varSign);
		return new LocalVariableInfoFetchVisitor(varSign);
	}
	
	
	
}